/*
 * File name: main.c
 *
 * Description: The entry of memtest tool
 *
 * Copyright (C) 2009, Easy Link(Beijing) Technology Co.,Ltd.
 *
 * Date         Modification            Name
 * ----------------------------------------------
 * 2009-03-13   Create                  Libo Jiao
 */

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "7250.h"

static void usage(void)
{

    printf( "Usage: %s [OPTION]\n"
            "A mem test tool by proc for Linux and other unix-like systems.\n\n"
            "  -o, --oil=<ooo.oooo>        : print <pid> mem infomaiton\n"
            "  -w, --water=<www.wwww>  : read smaps files on the <dir>\n"
            "  -t, --temp=<ttt.tttt>  : read smaps files on the <dir>\n"
            "  -h, --help             : display this help and exit\n"
            "  -v, --version          : output version information and exit\n\n",
        PACKAGE);
}


int main(int argc, char *argv[])
{
    int c;
    int index = 0;
    char diropt[256] = {0};
    int pidopt = -1;

    float oil, water, temp;
    char data[134]; 

    static struct option long_options[] =
    {
        { "oil",         required_argument, NULL, 'o' },
        { "water",         required_argument, NULL, 'w' },
        { "temp",         required_argument, NULL, 't' },
        { "help",        no_argument,       NULL, 'h' },
        { "version",     no_argument,       NULL, 'v' },
        { NULL, 0, NULL, 0 }
    };
    
    //get all information that from smaps!
    //proc_smaps_init();
    
    while ( (c = getopt_long(argc, argv, "o:w:t:hv", 
                    long_options, &index)) != -1)
    {
        switch (c)
        {
            /*
            case 0:
                printf("option %s", long_options[index].name);
                if (optarg)
                    printf(" with arg %s", optarg);
                printf("\n");
                exit(1);
                */
            case 'o':
                if (isdigit(optarg[0]))
                    oil = atof(optarg);
                
                //printf("----pid=%d----\n",pidopt);
                //output_proc_info(pidopt);
                break;
            case 'w':
                if (isdigit(optarg[0]))
                    water = atof(optarg);
                break;
            case 't':
                if (isdigit(optarg[0]))
                    temp = atof(optarg);
                break;
            case 'h':
                usage();
                exit(1);
            case 'v':
                printf ("%s version %s\n", PACKAGE, VERSION);
                printf ("Copyright (C) 2009,Beijing THHT Technology Co.,Ltd.\n\n");
                exit(1);
            default:
                exit(1);
        }
    }


   //  printf ("oil = %f, water = %f, temp = %f\n", oil, water, temp);

    oil = 11.0;
    water = 22.0;
    temp = 33.0;
    tt_get_7250_string(data, oil, water, temp);

    /*
    for (c=0;c<134;c++) {
        // printf ("%c",data[c]);
        if ( c % 40 == 39)
            ;
           // printf ("\n"); 
    }
    // printf ("\n");
    */

    return 0;
}
